import { createApp } from "vue";
import App from "./App.vue";

// custom element css
import "@shared/styles";
// 引入unocss
import "virtual:uno.css";
// svg icons
import "virtual:svg-icons-register";
// element css
import "element-plus/dist/index.css";
// element dark(内置暗黑模式)
import "element-plus/theme-chalk/dark/css-vars.css";

// element plus
import ElementPlus from "element-plus";
// element icons
import * as Icons from "@element-plus/icons-vue";
// custom directives
import directives from "@shared/directives";
// vue Router
import router from "@/routers";
// vue i18n
import I18n from "@/languages/index";
// pinia store
import pinia from "@shared/stores";

import { setCookieAccessToken, setCookieRefreshToken } from "@shared/utils";

if (process.env.NODE_ENV === "development") {
	setCookieAccessToken("c7e6bb73-9675-41af-a4fa-0e911714f89b");
	setCookieRefreshToken("7c51d8ca-2454-423a-be18-aac8d18ebb6a");
}

const app = createApp(App);

// 配置vue devtools
const win = window;

if (process.env.NODE_ENV === "development") {
	if ("__VUE_DEVTOOLS_GLOBAL_HOOK__" in win) {
		win.__VUE_DEVTOOLS_GLOBAL_HOOK__.Vue = app;
	}
}

// register the element Icons component
Object.keys(Icons).forEach(key => {
	app.component(key, Icons[key]);
});

app.use(ElementPlus).use(I18n).use(directives).use(router).use(pinia).mount("#app");
